﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class ChangePwd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["user"] == null)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请登录后再修改密码');\nlocation.href('Default.aspx');", true);
        }
        else
            Label1.Text = Session["user"].ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string uid = Label1.Text;
            string upwd = Md5.getMd5(pwd.Text);
            DbAccess db = new DbAccess();
            string sql = "update userInfo set pwd='" + upwd + "' where uid='" + uid + "'";
            if (db.ExecuteSql(sql))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('密码修改成功');\nlocation.href('Default.aspx');", true);

            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('密码修改失败');\nlocation.href('Default.aspx');", true);

            
            }

        }
        catch
        { 
        
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        pwd.Text = "";
        pwd1.Text = "";
    }
}
